package com.spdd.mt.biz.manager.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.spdd.mt.biz.constant.MtResponseStatus;
import com.spdd.mt.biz.constant.ResponseCode;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
public class WebResponse {

    // 根据抖店充值文档要求，默认都返回0
    @JsonProperty("code")
    private String code;

    @JsonProperty("status")
    private String status;

    @JsonProperty("msg")
    private String msg;

    // @JsonProperty("data")
    // private T data;

    protected WebResponse(String code, String status, String message) {
        this.code = code;
        this.status = status;
        this.msg = message;
    }

    public static WebResponse success() {
        return new WebResponse(ResponseCode.SUCCESS.getValue(), "", ResponseCode.SUCCESS.getDesc());
    }

    public static WebResponse success(String msg) {
        return new WebResponse(ResponseCode.SUCCESS.getValue(), "", msg);
    }

    public static WebResponse success(String status, String msg) {
        return new WebResponse(ResponseCode.SUCCESS.getValue(), status, msg);
    }

    public static WebResponse success(MtResponseStatus responseStatus) {
        return new WebResponse(ResponseCode.SUCCESS.getValue(), responseStatus.getValue(), responseStatus.getDesc());
    }

    public static WebResponse fail(ResponseCode responseCode, String status) {
        return new WebResponse(ResponseCode.FAILED.getValue(), status, responseCode.getDesc());
    }

    public static WebResponse fail(MtResponseStatus responseStatus) {
        return new WebResponse(ResponseCode.FAILED.getValue(), responseStatus.getValue(), responseStatus.getDesc());
    }

    public static WebResponse fail(MtResponseStatus responseStatus, String msg) {
        return new WebResponse(ResponseCode.FAILED.getValue(), responseStatus.getValue(), msg);
    }

    public static WebResponse fail(String msg) {
        return new WebResponse(ResponseCode.FAILED.getValue(), "", msg);
    }

    public static WebResponse fail(String status, String msg) {
        return new WebResponse(ResponseCode.FAILED.getValue(), status, msg);
    }

    public static WebResponse fail(String code, String status, String msg) {
        return new WebResponse(code, status, msg);
    }
}
